<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
cfc('core')->checklogin();
$return=array();
set_html('title','车辆管理');
if($_RQ['op']=='list'){
	//读取收货车辆列表
	$list=pdo_getall('jy_cxjxiche_mycar',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if($list){
		foreach($list as $k=>&$item){
			$item['code']=@json_decode($item['code'],true);
			$item['typetitle']=$this->car_type[$item['type']];
			$item['color']=$this->car_color[$item['color']];
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='set'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要设置的车辆','error');
	}
	pdo_update('jy_cxjxiche_mycar',array('isdefault'=>0),array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'isdefault'=>1));
	pdo_update('jy_cxjxiche_mycar',array('isdefault'=>1),array('id'=>$id,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if($_RQ['get']==1){
		exi('success');
	}else{
		exi('','','jy_cxjxiche/mycar/');
	}
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要删除的车辆','error');
	}
	pdo_delete('jy_cxjxiche_mycar',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	if($_RQ['get']==1){
		exi('success');
	}else{
		exi('','','jy_cxjxiche/mycar/');
	}
}